FROM 10.0.100.114/library/php:7.2-cli

ARG PHANTOMJS_VERSION=2.1.1

RUN set -ex; \
    ##
    # PhantomJS
    ##
    # Install phantomjs dependencies
    curl -LS "https://github.com/dustinblackman/phantomized/releases/download/${PHANTOMJS_VERSION}a/dockerized-phantomjs.tar.gz" -o dockerized-phantomjs.tar.gz; \
    tar -xf dockerized-phantomjs.tar.gz -C /; \
    # Install phantomjs binary
    curl -LS "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-x86_64.tar.bz2" -o phantomjs.tar.bz2; \
    mkdir -p phantomjs; \
    tar -xf phantomjs.tar.bz2 -C phantomjs --strip-components=1; \
    rm phantomjs.tar.bz2; \
    ( \
        cd phantomjs; \
        mv bin/phantomjs /usr/local/bin/ \
    ); \
    rm -r phantomjs; \
    chmod +rx /usr/local/bin/phantomjs

COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint

RUN chmod +x /usr/local/bin/docker-entrypoint; \
    apk add --no-cache --virtual .phantomjs-deps \
    fontconfig; \
    rm -rf /var/cache/apk/* /tmp/* /var/tmp/* /var/lib/apt/lists/*


ENTRYPOINT ["docker-entrypoint"]

CMD ["/usr/sbin/crond", "-l", "2", "-f"]
